﻿<?php
	$path = "";
	$rub="index";
	include_once($path.'configuration.php');
	/*traitements*/
	include_once($path.'head.php');
?>
	<div id="bodyWrapper">
		<h1>BIENVENUE DANS VOTRE SUPERVISEUR !</h1>
		<a href="" style="display:inline-block;margin:10px auto;">Cliquez-ici pour mettre à jour les informations ci-dessous</a>
		<div class="acc_salles">
				<?php
					$liste_m = $dbh->getAllMachine();
					$var_att_salle = false;	
					foreach($liste_m as $mach){
						if($mach['salle'] == NULL || $mach['salle']== "")
							$var_att_salle = True;
					}
						if($var_att_salle){
					?>
						<div class="acc_salle">
							<h2>En attente de salle:</h2>
						<?php
							$liste_machines = $dbh->getAllMachine();
							foreach($liste_machines as $machines){
								if($machines['salle'] == NULL || $machines['salle']== ""){
						?>
									<div class="acc_machine">
										<div class="acc_details_machine">
												<?php
													$liste_incident = $dbh->getAllIncidentByMachine($machines['id_machine']);
													if($liste_incident == NULL){
												?>
														<img src="<?php echo $path; ?>icons/up.png" alt="Everything's fine !"/><br/>
												<?php
													}
													else{
												?>
														<img src="<?php echo $path; ?>icons/down.png" alt="Something wrong..."/><br/>
												<?php
													}
												?>
													<h4><?php echo $machines['nom']; ?></h4><br/>
													<h4><?php echo $machines['IP']; ?></h4><br/>
										</div>
										<div class="acc_details_incident">
											<h3>Incidents</h3>
											<?php
												$liste_incident = $dbh->getAllIncidentByMachine($machines['id_machine']);
												foreach($liste_incident as $incidents){
													if($incidents['date_resolution'] == '0000-00-00 00:00:00'){
														$typping = new Type_Incident($dbh, $incidents['type']);
											 ?>
														<h4>Type</h4><?php echo $typping->getName();?>
														<h4>Detection</h4><?php echo $incidents['date_detection']; ?>
														<hr/>
											<?php
													}
												}
											?>
										</div>
									</div>
						<?php
								}
							}
						?>
						</div>
					<?php 
						}
				?>
			<?php
				$liste_salle = $dbh->getAllSalles();
				foreach($liste_salle as $salle){
					if($dbh->getAllMachineBySalle($salle['id_salle']) != null){
			?>
				<div class="acc_salle">
						<h2><?php echo $salle['nom_salle']; ?></h2>		
							<?php
								$liste_machine = $dbh->getAllMachineBySalle($salle['id_salle']);
									foreach($liste_machine as $machine){
								?>
										<div class="acc_machine">
											<div class="acc_details_machine">
												<?php
													$liste_incident = $dbh->getAllIncidentByMachine($machine['id_machine']);
													if($liste_incident == NULL){
												?>
														<img src="<?php echo $path; ?>icons/up.png" alt="Everything's fine !"/><br/>
												<?php
													}
													else{
												?>
														<img src="<?php echo $path; ?>icons/down.png" alt="Something wrong..."/><br/>
												<?php
													}
												?>
													<h4><?php echo $machine['nom']; ?></h4><br/>
													<h4><?php echo $machine['IP']; ?></h4><br/>
											</div>
											<div class="acc_details_incident">
												<h3>Incidents</h3>
											<?php
												$liste_incidents = $dbh->getAllIncidentByMachine($machine['id_machine']);
												foreach($liste_incidents as $incident){
													if($incident['date_resolution'] == '0000-00-00 00:00:00'){
														$typping = new Type_Incident($dbh, $incident['type']);
											 ?>
														<h4>Type</h4><?php echo $typping->getName();?>
														<h4>Detection</h4><?php echo $incident['date_detection']; ?>
														<hr/>
											<?php
													}
												}
											?>
											</div>
										</div>
								<?php
									}
							?>
				</div>
			<?php
					}
				}
			?>
		</div>
	</div>
<?php
	include_once($path.'footer.php');
?>